<template>
	<div>
		<h2>当前求和为: {{$store.state.sum}}</h2>
		<select v-model.number="num">
			<option value="1">1</option>
			<option value="2">2</option>
			<option value="3">3</option>
		</select>
		<button @click="increment">+</button>
		<button @click="decrement">-</button>
		<button @click="incrementIfOdd">当前求和为奇数再+</button>
		<button @click="incrementWait">等一等再+</button>
		<button @click="incrementServer">问问服务器到底+几</button>
	</div>
</template>

<script>
	export default {
		name: 'Count',
		data(){
			return{
				num:1
			}
		},
		methods: {
			increment(){
				this.$store.commit('JIA',this.num)
			},
			decrement(){
				this.$store.commit('JIAN',this.num)
			},
			incrementIfOdd(){
				this.$store.dispatch('jiaOdd',this.num)
			},
			incrementWait(){
				this.$store.dispatch('jiaWait',this.num)
			},
			incrementServer(){
				this.$store.dispatch('jiaServer')
			}
		},
	}
</script>

<style>
	*{
		margin-left: 20px;
	}
</style>